package com.department.mydepartment.entities;

import org.json.JSONObject;

import javax.persistence.*;
import java.sql.Timestamp;

@Entity
public class User {

    @Id
    @Column(unique = true,length = 36)
    private String userId;
    @Column(nullable = false)
    private String password;
    @Column(nullable = false)
    private Timestamp createTime;
    @Column(nullable = false)
    private Timestamp updateTime;

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }

    @Override
    public String toString() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.accumulate("userId",userId);
        jsonObject.accumulate("updateTime",updateTime);
        jsonObject.accumulate("createTime",createTime);
        jsonObject.accumulate("password",password);
        return jsonObject.toString();
    }

    public User(String userId, String password, Timestamp createTime, Timestamp updateTime) {
        this.userId = userId;
        this.password = password;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }

    public User() {
    }
}
